package com.ruoyi.system.mapper.waterMapper;

import com.ruoyi.system.domain.waterEnity.OrderEntity;
import com.ruoyi.system.domain.waterEnity.OrderItemEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface OrderMapper {
    /**
     * 订单管理
     * 1.查询全部订单
     */
    @Select("select * from water.order")
    List<OrderEntity> selectOrderList();
    /**
     * 2.修改订单支付状态
     */
    @Update("update water.order set pay_state = #{pay_state} where id=#{id}")
    String updateOrderById(String id);

    //根据order——id查询订单商品信息
    @Select("select * from water.orderitem where order_id = #{id}")
    List<OrderItemEntity> selectOrderItemByOrder_id(String id);
    //根据Orderid,查找订单信息
    @Select("select * from water.order where id = #{order_id}")
    OrderEntity selectOrderByOrder_id(String order_id);
    @Delete("<script>" +
            "delete from water.order where id in" +
            "<foreach collection='array' item='id' open='(' separator=',' close=')'>" +
            "#{id}" +
            "</foreach>" +
            "</script>")
    int deleteOrder(Long[] orderIds);
    @Delete("<script>" +
            "delete from water.orderitem where order_id in" +
            "<foreach collection='array' item='id' open='(' separator=',' close=')'>" +
            "#{id}" +
            "</foreach>" +
            "</script>")
    int deleteOrderItem(Long[] orderItemIds);
    @Select("select * from water.order where pay_state = #{pay_state}")
    List<OrderEntity> selectOrderByPay_state(String pay_state);
    @Select("select * from water.order where state = #{state}")
    List<OrderEntity> selectOrderByState(String state);
    @Select("select * from water.order where id = #{order_id}")
    List<OrderEntity> selectOrderByOrder_id2(String order_id);
}
